package com.igroupes.ovineherd.enums;

import static com.igroupes.ovineherd.constant.Constants.SEQUENCE_RESULT_GEN_EXCEPTION;
import static com.igroupes.ovineherd.constant.Constants.SEQUENCE_RESULT_KEY_NOT_FOUND;

public enum SequenceExceptionEnum implements CodeEnum<Integer> {
    GEN_EXCEPTION(SEQUENCE_RESULT_GEN_EXCEPTION, ErrorCode.SEQUENCE_KEY_NOT_FOUND), KEY_NOT_FOUND(SEQUENCE_RESULT_KEY_NOT_FOUND, ErrorCode.SEQUENCE_KEY_NOT_FOUND);
    private int result;
    private ErrorCode errorCode;


    SequenceExceptionEnum(int result, ErrorCode errorCode) {
        this.result = result;
        this.errorCode = errorCode;
    }

    public ErrorCode getErrorCode() {
        return errorCode;
    }

    public static boolean isError(long result){
        return  result == SEQUENCE_RESULT_GEN_EXCEPTION
                || result == SEQUENCE_RESULT_KEY_NOT_FOUND;
    }

    @Override
    public Integer getCode() {
        return result;
    }
}
